home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14145 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.duke.edu!usenet
  2. From: kev@acpub.duke.edu (Kevin Daniels)
  3. Newsgroups: comp.lang.c
  4. Subject: help with program
  5. Date: 11 Apr 1996 22:50:22 -0400
  6. Organization: Duke University, Durham, NC, USA
  7. Message-ID: <4kkgde$t2m@news.duke.edu>
  8. NNTP-Posting-Host: teer10.acpub.duke.edu
  9.  
  10.  
  11. Can anyone tell me why the following slice of code might be giving the 
  12. unwanted behavior shown below?
  13.  
  14.  
  15. void g_find_player1_human_move(void)
  16. {
  17.   int curr_row;
  18.   int curr_col;
  19.   int dest_row;
  20.   int dest_col;
  21.   int ok = 0;
  22.   int val;
  23.   int lcv;
  24.  
  25.   while (!ok) {
  26.  
  27.     printf("\n\nmove from row -> ");
  28.     scanf("%d",&curr_row);
  29.     printf("\n\nmove from col -> ");
  30.     scanf("%d",&curr_col);
  31.     printf("\n\nmove to row -> ");
  32.     scanf("%d",&dest_row);
  33.     printf("\n\nmove to col -> ");
  34.     scanf("%d",&dest_col); 
  35.     
  36.     for(lcv = 1; lcv <=40; lcv ++) {
  37.       if((RED_ALIVE.p[lcv].row_pos == curr_row) && (RED_ALIVE.p[lcv].col_pos == curr_col) && (RED_ALIVE.p[lcv].placed_on_board == 1)) {
  38.     ok = g_is_legal_move(RED_ALIVE.p[lcv].row_pos,RED_ALIVE.p[lcv].col_pos,RED_ALIVE.p[lcv].row_pos,RED_ALIVE.p[lcv].col_pos,P1_TURN);
  39.     if (ok) {
  40.       g_make_move(RED_ALIVE.p[lcv].row_pos,RED_ALIVE.p[lcv].col_pos,RED_ALIVE.p[lcv].row_pos,RED_ALIVE.p[lcv].col_pos,P1_TURN);
  41.     }
  42.       }
  43.     }
  44.   }
  45. }
  46.  
  47.  
  48. THE UNWANTED BEHAVIOR --
  49.  
  50. It keeps printing out the lines
  51.  
  52. move from row ->
  53.  
  54. move from col ->
  55.  
  56. move to row ->
  57.  
  58. move to row ->
  59.  
  60. without asking the user for his input.  I am woring on a UNIX system on
  61. a university account, if that helps.
  62.  
  63. If anyone can help, please e-mail me at kev@acpub.duke.edu
  64.  
  65. thank you
  66.